home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.direct.ca!usenet
- From: etoivane@direct.ca (Ed Toivanen)
- Newsgroups: comp.lang.c
- Subject: Re: Binary files ?
- Date: 25 Feb 1996 22:05:29 GMT
- Organization: Your Organization
- Message-ID: <4gqmf9$jno@aphex.direct.ca>
- References: <4gheee$bvr@ci.ist.utl.pt>
- NNTP-Posting-Host: 204.174.243.150
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.6
-
-
- ># include <stdio.h>
- >
- >
- >void main()
- >{
- >
- > /*write file*/
- > int n;
- > unsigned char mat[200];
- > FILE *f=fopen("teste","w");
- should be "w+b"
- > for (n=0;n<200;n++) mat[n]=n; /*init matrix*/
- > fwrite(mat,200,1,f);
- > fclose(f);
- >
- > /*reset matrix*/
- > for (n=0;n<200;n++) mat[n]=0;
- >
- > /*read file*/
- > f=fopen("teste","r");
- don't open it again
- > fread(mat,200,1,f);
- middle two params reversed
- > fclose(f);
- > for (n=0;n<200;n++) printf("%d ",mat[n]);/*print it*/
- >}
-
- Just a quick pass, I still might have missed something
- Ed
-
- >
- >// The main difference between man and animal is that man possesses the \\
- >//hability to think he is rational... \\
- >E-mail : l40128@alfa.ist.utl.pt
- >
-
-